import { NodeStatus } from "../../common/Enum"
import BTNode from "./BTNode"

/** 继承该节点的节点，不能作为叶子节点 */
export default abstract class BTParent extends BTNode {
    children: Array<BTNode> = []
    private _index: number = 0
    get index() {
        return this._index
    }
    set index(index: number) {
        this._index = index
    }

    constructor(children: Array<BTNode>) {
        super()
        this.children = children
    }

    /** 装饰 */
    decorate(status: NodeStatus) {
        return status
    }

    /** 是否可执行 */
    abstract canExecute(): boolean

    /** 当前子节点是否可执行 */
    abstract onChildExecuted(status: NodeStatus, index?: number): void

    onConditionalAbort(index: number) {

    }

    canRunParallelChildren(): boolean {
        return false
    }

    onChildStarted() {

    }
}